#ifndef QV_LOCAL_H
#define QV_LOCAL_H


/* make Q3 game datatypes & functions available to all QV headers */
#include "../game/g_local.h"
/* included for characteristic defs */
#include "../game/chars.h"


/* This stuff makes sure we compile on MS VC */
#if (_MSC_VER > 1300)
#include <stdio.h>
#define snprintf _snprintf
#endif

/* Bot main characteristics */
#define QV_BOT_SKILL_LVL		"1"
#define QV_BOT_MODEL			"sorlag"
#define QV_BOT_GENDER			"it"
#define QV_BOT_NAME				"qv-bot"
#define QV_BOT_CHAT_NAME		"sorlag"

/* Max string size */
#define LINE_BUF_SIZE			256

/* Strings for botnames */
#define QV_RANDOM_BOT_STR		"-R"
#define QV_CHILD_BOT_STR		"-C"

/* Gen types */
enum QV_GEN_TYPE
{
	BASIC_GENS = 1,
	ITEM_WEIGHTS = 2
};

/* Gen numbers */
#define QV_NUM_BOT_CHARS		49
#define QV_NUM_ITEM_WEIGHTS		29

/* Gene names */
#define QV_BOT_CHARACTS	{"CHARACTERISTIC_NAME", "CHARACTERISTIC_GENDER", "CHARACTERISTIC_ATTACK_SKILL",			\
						"CHARACTERISTIC_WEAPONWEIGHTS", "CHARACTERISTIC_VIEW_FACTOR",							\
						"CHARACTERISTIC_VIEW_MAXCHANGE", "CHARACTERISTIC_REACTIONTIME",							\
						"CHARACTERISTIC_AIM_ACCURACY", "CHARACTERISTIC_AIM_ACCURACY_MACHINEGUN",				\
						"CHARACTERISTIC_AIM_ACCURACY_SHOTGUN", "CHARACTERISTIC_AIM_ACCURACY_ROCKETLAUNCHER",	\
						"CHARACTERISTIC_AIM_ACCURACY_GRENADELAUNCHER", "CHARACTERISTIC_AIM_ACCURACY_LIGHTNING", \
						"CHARACTERISTIC_AIM_ACCURACY_PLASMAGUN", "CHARACTERISTIC_AIM_ACCURACY_RAILGUN",			\
						"CHARACTERISTIC_AIM_ACCURACY_BFG10K", "CHARACTERISTIC_AIM_SKILL",						\
						"CHARACTERISTIC_AIM_SKILL_ROCKETLAUNCHER", "CHARACTERISTIC_AIM_SKILL_GRENADELAUNCHER",	\
						"CHARACTERISTIC_AIM_SKILL_PLASMAGUN", "CHARACTERISTIC_AIM_SKILL_BFG10K",				\
						"CHARACTERISTIC_CHAT_FILE",	"CHARACTERISTIC_CHAT_NAME", "CHARACTERISTIC_CHAT_CPM",		\
						"CHARACTERISTIC_CHAT_INSULT", "CHARACTERISTIC_CHAT_MISC",								\
						"CHARACTERISTIC_CHAT_STARTENDLEVEL", "CHARACTERISTIC_CHAT_ENTEREXITGAME",				\
						"CHARACTERISTIC_CHAT_KILL",	"CHARACTERISTIC_CHAT_DEATH",								\
						"CHARACTERISTIC_CHAT_ENEMYSUICIDE", "CHARACTERISTIC_CHAT_HITTALKING",					\
						"CHARACTERISTIC_CHAT_HITNODEATH", "CHARACTERISTIC_CHAT_HITNOKILL",						\
						"CHARACTERISTIC_CHAT_RANDOM", "CHARACTERISTIC_CHAT_REPLY",	"CHARACTERISTIC_CROUCHER",	\
						"CHARACTERISTIC_JUMPER", "CHARACTERISTIC_WEAPONJUMPING", "CHARACTERISTIC_GRAPPLE_USER",	\
						"CHARACTERISTIC_ITEMWEIGHTS", "CHARACTERISTIC_AGGRESSION",								\
						"CHARACTERISTIC_SELFPRESERVATION", "CHARACTERISTIC_VENGEFULNESS",						\
						"CHARACTERISTIC_CAMPER", "CHARACTERISTIC_EASY_FRAGGER", "CHARACTERISTIC_ALERTNESS",		\
						"CHARACTERISTIC_FIRETHROTTLE", "CHARACTERISTIC_WALKER"}

#define QV_ITEM_CHARACTS	{"FS_HEALTH","FS_ARMOR","W_GAUNTLET","W_GRAPPLE","W_SHOTGUN",			\
							"W_MACHINEGUN","W_GRENADELAUNCHER","W_ROCKETLAUNCHER","W_RAILGUN",		\
							"W_BFG10K","W_LIGHTNING","W_PLASMAGUN","GWW_SHOTGUN","GWW_MACHINEGUN",	\
							"GWW_GRENADELAUNCHER","GWW_ROCKETLAUNCHER","GWW_RAILGUN","GWW_BFG10K",	\
							"GWW_LIGHTNING","GWW_PLASMAGUN","W_TELEPORTER","W_MEDKIT","W_QUAD",		\
							"W_ENVIRO","W_HASTE","W_INVISIBILITY","W_REGEN","W_FLIGHT",				\
							"FLAG_WEIGHT"}


/* Settings IDs */
#define QV_NUM_SETTINGS					13

#define QV_SETTING_BOTS					0
#define QV_SETTING_MAXROUNDS			1
#define QV_SETTING_SWAPPOINT_RATE		2
#define QV_SETTING_CROSSOVER_RATE		3
#define QV_SETTING_MUTATION_MU			4
#define QV_SETTING_MUTATION_SIGMA		5
#define QV_SETTING_USE_WEIGHTS			6
#define QV_SETTING_DEPENDENCIES			7
#define QV_SETTING_SELECTION_MODEL		8
#define QV_SETTING_FITNESS_FUNCTION		9
#define QV_SETTING_TESTMODE				10
#define QV_SETTING_TESTROUNDS			11
#define QV_SETTING_TESTBOTS				12

#define QV_SETTING_IDS	{ "Main:Bots", "Main:MaxRounds", "Genetic:SwappointRate", "Genetic:CrossoverRate",	\
	"Genetic:MutationMu", "Genetic:MutationSigma", "Genetic:UseWeights", "Genetic:Dependencies",			\
						"Genetic:SelectionModel", "Genetic:FitnessFunction", "Test:TestMode",				\
						"Test:TestRounds", "Test:TestBots" }

/* Fuzzy weight files */
#define QV_BOT_WEAP_FILE	"bots/sorlag_w.c"
#define QV_BOT_ITEM_FILE	"bots/sorlag_i.c"
#define QV_BOT_CHAT_FILE	"bots/sorlag_t.c"


/* Struct for all the gens of a bot */
typedef struct QV_genData {
	char basic_gen_data[QV_NUM_BOT_CHARS][LINE_BUF_SIZE];		/* basic genes */
	char item_gen_data[QV_NUM_ITEM_WEIGHTS][LINE_BUF_SIZE];		/* item weight genes */
	char parent1[LINE_BUF_SIZE];
	char parent2[LINE_BUF_SIZE];
} QV_genData;

/* wrapper struct to store five extra QV bot-chars */
typedef struct QV_botData {
	char* botAltName;	/* name of bot used for round */
	int roundNum;		/* round bot participated in */
	int numFrags;		/* how many frags bot scored */
	int numDeaths;		/* how many deaths bot suffered */
	int fitness;		/* fitness val before shifting */
	int rank;		/* ranking in round */
} QV_botData;

/* Settings struct for user settings */
typedef struct QV_settings {
	int bots;
	int maxrounds;
	float swappoint_rate;
	float crossover_rate;
	float mutation_mu;
	float mutation_sigma;
	int use_weights;
	int dependencies;
	int selection_model;
	int fitness_function;
	int testmode;
	int testrounds;
	int testbots;
} QV_settings;

#endif
